﻿package mortal.game.view.petNew
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import flash.utils.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.skill.*;

    public class NewPetCache extends Object
    {
        private var _pet:SPublicPet2;
        private var _petConfig:TMountConfig;

        public function NewPetCache()
        {
            return;
        }// end function

        public function set pet(param1:SPublicPet2) : void
        {
            this._pet = param1;
            return;
        }// end function

        public function get pet() : SPublicPet2
        {
            return this._pet;
        }// end function

        public function get petConfig() : TMountConfig
        {
            if (this._petConfig == null || this._petConfig && this._petConfig.code != this.pet.code)
            {
                this._petConfig = MountConfig.instance.getFashionInfoByCode(EAdvanceComponentType._EAdvanceComponentTypePet, this.pet.code);
            }
            return this._petConfig;
        }// end function

        public function get getTalentSkillList() : Vector.<SkillInfo>
        {
            var _loc_3:SkillInfo = null;
            var _loc_1:* = new Vector.<SkillInfo>;
            var _loc_2:* = PetConst.TALENT_SKILL_START_POS;
            while (_loc_2 <= PetConst.TALENT_SKILL_END_POS)
            {
                
                _loc_3 = this.getPetSkill(_loc_2);
                if (_loc_3 == null)
                {
                }
                else
                {
                    _loc_1.push(_loc_3);
                }
                _loc_2++;
            }
            return _loc_1;
        }// end function

        public function getPetSkill(param1:int) : SkillInfo
        {
            var _loc_2:* = this.pet.skillIds;
            var _loc_3:* = _loc_2[param1];
            if (_loc_3 == 0)
            {
                return null;
            }
            var _loc_4:* = SkillConfig.instance.getInfoById(_loc_3);
            var _loc_5:* = new SkillInfo();
            _loc_5.tSkill = _loc_4;
            return _loc_5;
        }// end function

        public function getPetAdvanceGrouthNum(param1:ItemData) : Array
        {
            var _loc_2:int = 1;
            if (Cache.instance.newPet.pet)
            {
                _loc_2 = Cache.instance.newPet.pet.code;
            }
            var _loc_3:* = MountConfig.instance.getFashionInfoByCode(EAdvanceComponentType._EAdvanceComponentTypePet, _loc_2);
            var _loc_4:Array = [0, 10];
            if (this.pet)
            {
                _loc_4[0] = this.pet.totalGrowthNum;
            }
            else
            {
                _loc_4[0] = 0;
            }
            _loc_4[1] = _loc_3.maxUseGrowth;
            return _loc_4;
        }// end function

        public function getPetAdvanceTalentNum(param1:ItemData) : Array
        {
            var _loc_2:int = 1;
            if (Cache.instance.newPet.pet)
            {
                _loc_2 = Cache.instance.newPet.pet.code;
            }
            var _loc_3:* = MountConfig.instance.getFashionInfoByCode(EAdvanceComponentType._EAdvanceComponentTypePet, _loc_2);
            var _loc_4:Array = [0, 10];
            if (this.pet)
            {
                _loc_4[0] = this.pet.totalTalentNum;
            }
            else
            {
                _loc_4[0] = 0;
            }
            _loc_4[1] = _loc_3.maxUseTalent;
            return _loc_4;
        }// end function

        public function get getShowCode() : int
        {
            var _loc_1:* = Cache.instance.newPet.pet.sharpId;
            if (_loc_1 > 30)
            {
                _loc_1 = Cache.instance.newPet.pet.code;
            }
            return _loc_1;
        }// end function

    }
}
